<template>
  <div class="content-box">
    <div v-if="hideTwo == 'first'">
    <nav-title title="基本信息" />
    <div class="line">
      <span class="important">*</span>
      <div class="label">姓名</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.name" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">姓名拼音</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.nameAc" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">曾用名</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsUsedName" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">性别</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="sexVal" v-model="basicInfo.sex"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">国籍</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="couVal" v-model="basicInfo.country"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">出生日期</div>
      <div class="value">
        <group>
          <datetime value-text-align="left" readonly placeholder="请选择" v-model="basicInfo.birthdate"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">民族</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="natVal" v-model="basicInfo.ethnicGrpCd"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">籍贯</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" readonly v-model="basicInfo.nativePlaceChn">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">最高学历</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="heduVal" v-model="basicInfo.highestEducLvl"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">毕业学校</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cSchool" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">专业</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cMajor" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">参加工作时间</div>
      <div class="value">
        <group>
          <datetime readonly value-text-align="left" readonly placeholder="请选择" v-model="basicInfo.startDtChn"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">入本公司时间</div>
      <div class="value" readonly="readonly">
        <group>
          <datetime value-text-align="left" readonly placeholder="请选择" v-model="basicInfo.rsWklifBgnDt"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">现在职称</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cPosition" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">政治面貌</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="polsVal" v-model="basicInfo.politicalStaChn"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">入党(团)时间</div>
      <div class="value">
        <group>
          <datetime value-text-align="left" readonly placeholder="请选择" v-model="basicInfo.cDate"></datetime>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">有无驾照</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="lcList" v-model="basicInfo.cYesNo"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">身高(CM)</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsPersHeight" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">体重(KG)</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.rsPersWeight" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">血型</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="blodVal" v-model="basicInfo.rsBloodType"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">健康状况</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="helVal" v-model="basicInfo.rsHealthStatus"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">婚姻状况</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="mryVal" v-model="basicInfo.marStatus"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">生育状况</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="bearVal" v-model="basicInfo.cBear"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">证件类型</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio readonly placeholder="请选择" readonly :options="itVal" v-model="basicInfo.nationalIdType"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">证件号码</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.nationalId" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">户籍地址</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.addresslong1" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">家庭详细地址</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.addresslong3" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">现在居住地址</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.addresslong2" readonly="readonly">
      </div>
    </div>
    <div class="line" style="border-bottom:0;">
      <span class="important">*</span>
      <div class="label">指定送达地址</div>
      <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="sendVal" v-model="basicInfo.cSendType"></popup-radio>
        </group>
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label"></div>
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cAddress" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">住宅电话</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.phone1" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">手机号码</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.phone" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important">*</span>
      <div class="label">个人Email</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.emailAddr" readonly="readonly">
      </div>
    </div>
    <div class="line">
      <span class="important"></span>
      <div class="label">个人档案所在地</div>
      <div class="value">
        <input type="text" placeholder="请在此输入" v-model="basicInfo.cArchiveAddr" readonly="readonly">
      </div>
    </div>
    </div>

    <div v-if="hideTwo == 'second'">
      <nav-title title="个人特长及兴趣爱好" />
      <div class="line">
        <span class="important"></span>
        <div class="label">个人特长</div>
        <div class="value">
          <input type="text" placeholder="请在此输入" v-model="basicInfo.cDescrlong" readonly="readonly">
        </div>
      </div>
      <div class="line">
        <span class="important"></span>
        <div class="label">兴趣爱好</div>
        <div class="value">
          <input type="text" placeholder="请在此输入" v-model="basicInfo.rsHobby" readonly="readonly">
        </div>
      </div>
    </div>

    <div v-if="hideTwo == 'third'">
    <nav-title title="其他需要说明的情况" />
    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">是否有过犯罪记录？</div>
      <!-- <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="lcList" v-model="basicInfo.cYesNo4"></popup-radio>
        </group>
      </div> -->
    </div>
    <div class="line">
      <!-- <span class="important"></span>
      <div class="label"></div> -->
      <div class="value" v-if="basicInfo.cYesNo1 == 'Y'">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong1" readonly="readonly">
      </div>
      <div class="value" style="padding-left:15px;" v-if="basicInfo.cYesNo1 == 'N'">
        无
      </div>
    </div>

    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">曾否因大病入院或患有特殊疾病？</div>
      <!-- <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="lcList" v-model="basicInfo.cYesNo1"></popup-radio>
        </group>
      </div> -->
    </div>
    <div class="line">
      <!-- <span class="important"></span>
      <div class="label"></div> -->
      <div class="value" v-if="basicInfo.cYesNo2 == 'Y'">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong2" readonly="readonly">
      </div>
      <div class="value" style="padding-left:15px;" v-if="basicInfo.cYesNo2 == 'N'">
        无
      </div>
    </div>

    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">是否对其他公司负竞业限制义务？</div>
      <!-- <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="lcList" v-model="basicInfo.cYesNo2"></popup-radio>
        </group>
      </div> -->
    </div>
    <div class="line" v-if="basicInfo.cYesNo3 == 'Y'">
      <!-- <span class="important"></span>
      <div class="label"></div> -->
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong3" readonly="readonly">
      </div>
      <div class="value" style="padding-left:15px;" v-if="basicInfo.cYesNo3 == 'N'">
        无
      </div>
    </div>

    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">是否曾在本集团任职或建立过劳动关系？</div>
      <!-- <div class="value">
        <group label-width="5em">
          <popup-radio placeholder="请选择" readonly :options="lcList" v-model="basicInfo.cYesNo3"></popup-radio>
        </group>
      </div> -->
    </div>
    <div class="line">
      <!-- <span class="important"></span>
      <div class="label"></div> -->
      <div class="value">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong4" readonly="readonly">
      </div>
    </div>
    <div class="line" style="border-bottom:0;">
      <span class="important"></span>
      <div class="label">其他补充说明</div>
    </div>
    <div class="line">
      <div class="value" v-if="basicInfo.cYesNo4 == 'Y'">
        <input type="text" style="line-height:40px;" placeholder="请在此输入" v-model="basicInfo.cDescrlong5" readonly="readonly">
      </div>
      <div class="value" style="padding-left:15px;" v-if="basicInfo.cYesNo4 == 'N'">
        无
      </div>
    </div>
    </div>
    
    <div class="bsbtn" @click="save" v-if="showOr">
      保存
    </div>
  </div>

</template>

<script>
import { Datetime, Group,PopupRadio } from 'vux'
import { getDicItem, saveBasicUser, getCountry, getNation, getIdType, getQrmsg ,getBasicUser} from '../../../api/api'
import { json2Form } from '../../../util/http'

export default {

  name: 'basicif',
  components: {
    Datetime, Group, PopupRadio
  },
  mounted(){
    if(!this.$route.params.ctn){
      this.hideTwo = this.$route.params.whc
      this.showOr = false
      this.getBsInfo()
    }
    this.getsexDic()
    this.getcoulb()
    this.getnatlb()
    this.gethlDic()
    this.getpolDic()
    this.getbloodDic()
    this.gethelDic()
    this.getmarDic()
    this.getbearDic()
    this.getIdlb()
    this.getsendDic()
  },
  data() {
    return {
      basicInfo:{
        emplid: '',
        cTransactionNbr:'',
        cEmplFrom:130,
        regRegion:1,
        rsHirSource:10,
        rsHirStatus:'W',
        cModStauts:''
      },
      sexVal:[],
      couVal:[],
      natVal:[],
      heduVal:[],
      polsVal:[],
      blodVal:[],
      helVal:[],
      mryVal:[],
      bearVal:[],
      itVal:[],
      sendVal:[],
      lcList: [{value: '有', key: 'Y'},{value: '无', key: 'N'}],
      showOr:true,
      hideTwo:'',
      lastCh: {
        emplid: '',
      }
    }
  },
  created() {
    this.getBsif()
  },
  methods: {
    save() {
      this.basicInfo.sex=this.basicInfo.sex[0]
      this.basicInfo.country=this.basicInfo.country[0]
      this.basicInfo.ethnicGrpCd=this.basicInfo.ethnicGrpCd[0]
      this.basicInfo.highestEducLvl=this.basicInfo.highestEducLvl[0]
      this.basicInfo.politicalStaChn=this.basicInfo.politicalStaChn[0]
      this.basicInfo.rsBloodType=this.basicInfo.rsBloodType[0]
      this.basicInfo.rsHealthStatus=this.basicInfo.rsHealthStatus[0]
      this.basicInfo.marStatus=this.basicInfo.marStatus[0]
      this.basicInfo.cBear=this.basicInfo.cBear[0]
      this.basicInfo.nationalIdType=this.basicInfo.nationalIdType[0]
      this.basicInfo.cSendType=this.basicInfo.cSendType[0]
      this.basicInfo.name = this.basicInfo.firstName+this.basicInfo.lastName
      this.basicInfo.cTransactionNbr = this.lastCh.cTransactionNbr
      this.basicInfo.cModStauts = 'U'
      alert(this.basicInfo.cTransactionNbr)
      saveBasicUser(json2Form(this.basicInfo)).then(res => {
        if(res && res.retCode === '000000' ){
          this.$router.push({
            name: 'userBase',
            params:{
              cnta: this.basicInfo.cTransactionNbr
            }
          });
        }else{
          alert(res.retMsg)
        }
      })
      // if(this.skill.length === 0){
      //   this.$vux.alert.show({
      //     title: '警告',
      //     content: '请选择技能名称'
      //   });
      //   return;
      // }
    },

    getBsInfo() {
      getBasicUser(this.lastCh).then(res => {
        if (res && res.retCode === '000000') {
          console.log(res.retData)
          this.basicInfo = res.retData
          this.getcoulb(res.retData.country)
          this.getnatlb(res.retData.ethnicGrpCd)
        } else {
          alert(res.retMsg);
        }
      })
    },

    //性别
    getsexDic() {
      this.sexVal = []
      let params = {
        fileName: 'SEX'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.sexVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
        console.log(res)
      }).catch(res => {

      })
    },
    //国籍
    getcoulb(cou) {
      getCountry().then(res => {
        res.retData.forEach((val) => {
          this.couVal.push({value: val.descrshort, key: val.country})
          if(val.country == cou){
            this.basicInfo.country = val.descrshort
          }
        });
      })
    },
    //民族
    getnatlb(nat) {
      getNation().then(res => {
        res.retData.forEach((val) => {
          this.natVal.push({value: val.descrshort, key: val.ethnicGrpCd})
          if(val.ethnicGrpCd == nat){
            this.basicInfo.ethnicGrpCd = val.descrshort
          }
        });
      })
    },
    //学历
    gethlDic() {
      this.labelVal = []
      let params = {
        fileName: 'HIGHEST_EDUC_LVL'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.heduVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //政治
    getpolDic() {
      let params = {
        fileName: 'POLITICAL_STA_CHN'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.polsVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //血型
    getbloodDic() {
      let params = {
        fileName: 'RS_BLOOD_TYPE'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.blodVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //健康
    gethelDic() {
      let params = {
        fileName: 'RS_HEALTH_STATUS'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.helVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //婚姻
    getmarDic() {
      let params = {
        fileName: 'MAR_STATUS'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.mryVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },

    //生育
    getbearDic() {
      let params = {
        fileName: 'C_BEAR'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.bearVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    //证件
    getIdlb() {
      getIdType().then(res => {
        res.retData.forEach((val) => {
          this.itVal.push({value: val.descr.substring(3), key: val.nationalIdType})
        });
      })
    },
    //指定送达
    getsendDic() {
      let params = {
        fileName: 'C_SEND_TYPE'
      }
      getDicItem(params).then(res => {
        res.retData.forEach((val) => {
          this.sendVal.push({value: val.xlatshortname, key: val.fieldvalue})
        });
      }).catch(res => {

      })
    },
    removeTime(inval,rmval) {
      Object.entries(inval).forEach(([key,val]) => {
        if(rmval.hasOwnProperty(key)){
          rmval[key] = val
          console.log(1)
        }
      })
    },
    getBsif() {
      if(this.$route.params.ctn){
        this.lastCh.cTransactionNbr = this.$route.params.ctn
        this.lastCh.emplid = this.$route.params.emplid
        this.getBsInfo()
        this.hideTwo = this.$route.params.whc
        if(!this.$route.params.ctn){
          this.showOr = false
        }
      }
    }
  },
  watch: {
    '$route': 'getBsif'
  }
}
</script>
<style type="text/scss" lang="scss"  scoped>
@import "./personstyle";
</style>
